﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Drawing;

public partial class Mod_FlatManger_frm_CorporationSet : System.Web.UI.Page
{
    private void ControlButtonVisible(string UserLogID, string CurrPageID)
    {
        ClsMenuDAL cls_Menu = new ClsMenuDAL();
        DataSet dst = cls_Menu.GetCurrUserButtonPopedom(UserLogID, CurrPageID);

        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            int intCount = dst.Tables[0].Rows.Count - 1;

            for (int i = intCount; i >= 0; i--)
            {
                int intButtonID = Int32.Parse(dst.Tables[0].Rows[i][2].ToString());

                switch (intButtonID)
                {
                    case 0:
                        this.panAdd.Visible = true;
                        break;
                    case 1:
                        this.hidButtonEdit.Value = intButtonID.ToString();
                        break;
                    case 2:
                        this.panDelete.Visible = true;
                        break;
                    case 3:
                        this.lbtnDelete1.Enabled = true;
                        break;
                    case 4:
                        this.panAudit.Visible = true;
                        break;
                    case 5:
                        this.hidButtonOAudit.Value = intButtonID.ToString();
                        break;
                    case 6:
                        this.panRef.Visible = true;
                        break;
                    case 7:
                        this.panSearch.Visible = true;
                        break;
                    case 20:
                        this.panPrint.Visible = true;
                        break;
                }
            }
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();

        string strUserID = cls_Property.SetOrGetUserID;

        if (strUserID != "")
        {
            if (!IsPostBack)
            {
                ////////////////按钮权限控制 Begin /////////////////////////
                string strCurrPageID = this.Page.Request.Params["PageID"];
                this.ControlButtonVisible(strUserID, strCurrPageID);
                //////////////////////  End ///////////////////////////////

                this.GetCorporationSets();
            }
            else
            {
                this.lblJs.Text = "";//清空JS脚本
            }

            this.ibtnDelete0.Attributes.Add("onClick", "return confirm('您真的要作废所选的项吗？');");
            this.lbtnDelete0.Attributes.Add("onClick", "return confirm('您真的要作废所选的项吗？');");
            this.lbtnDelete1.Attributes.Add("onClick", "return confirm('彻底作废将无法恢复数据。您真的要作废所选的项吗？');");
            this.txt6.Attributes.Add("onblur", "if(value.Trim() != '' && ! /(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(value)) {alert('电话号码一格式不正确！');this.value='';this.select();this.focus();}");
            this.txt7.Attributes.Add("onblur", "if(value.Trim() != '' && ! /(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(value)) {alert('电话号码二格式不正确！');this.value='';this.select();this.focus();}");
            this.txt8.Attributes.Add("onblur", "if(value.Trim() != '' && ! /(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(value)) {alert('传真号码一格式不正确！');this.value='';this.select();this.focus();}");
            this.txt9.Attributes.Add("onblur", "if(value.Trim() != '' && ! /(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(value)) {alert('传真号码二格式不正确！');this.value='';this.select();this.focus();}");
            this.txt11.Attributes.Add("onblur", "if(value.Trim() != '' && ! /^[1-9]\\d{5}$/.test(value)) {alert('邮政编码格式不正确！');this.value='';this.select();this.focus();}");
            this.txt12.Attributes.Add("onblur", "if(value.Trim() != '' && ! (new RegExp(/^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$/).test(value))) {alert('邮箱格式不正确！');this.value='';this.select();this.focus();}");
        }
        else
        {
            ClsMenuDAL cls_Menu = new ClsMenuDAL();
            string strMessage = cls_Menu.GetSystemCode("1", "00", this.txt1.Text.Trim(), 47);//取消当前系统编码
            this.Page.Session.Remove("SetOrGetUserID");
            this.lblJs.Text = "<script>parent.window.location.href='../index.aspx'</script>";
        }
    }

    public void ChangPage(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_CorporationSet = new ClsPropertyDAL();
        DataSet dst = cls_CorporationSet.SetOrGetCorporationDataSet;

        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            string strKey = ((LinkButton)sender).CommandName;
            int intPageIndex = this.dgrdResult.CurrentPageIndex;
            int intPageCounts = this.dgrdResult.PageCount;

            if (strKey == "0")
            {
                intPageIndex = 0;
            }
            else if (strKey == "1")
            {
                if (intPageIndex > 0) intPageIndex -= 1;
            }
            else if (strKey == "2")
            {
                if (intPageIndex < intPageCounts - 1) intPageIndex += 1;
            }
            else
            {
                intPageIndex = intPageCounts - 1;
            }

            this.BindCorporationSetsByDataView(dst, intPageIndex);
        }
    }

    public void AddCorporationSetInfo(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();

        string strUserIDD = cls_Property.SetOrGetUserID;

        if (strUserIDD != "")
        {
            string strcomp_ID = this.txt1.Text.Trim();//编号
            string strcomp_Name = this.txt2.Text.Trim();//企业简称
            string strcomp_desc = this.txt3.Text.Trim();//企业全称
            string strcomp_eng = "";//英文名称
            string strcomp_boss = this.txt5.Text.Trim();//法人代表
            string strcomp_tel1 = this.txt6.Text.Trim();//电话一
            string strcomp_tel2 = this.txt7.Text.Trim();//电话二
            string strcomp_fax1 = this.txt8.Text.Trim();//传真一
            string strcomp_fax2 = this.txt9.Text.Trim();//传真二
            string strcomp_address = this.txt10.Text.Trim();//详细地址
            string strcomp_post = this.txt11.Text.Trim();//邮编
            string strcomp_email = this.txt12.Text.Trim();//邮箱
            string strcomp_website = this.txt13.Text.Trim();//网址
            string strcomp_bank = this.txt14.Text.Trim();//开户银行
            string strcomp_accno = this.txt15.Text.Trim();//银行帐号
            string strcomp_taxno = this.txt16.Text.Trim();//税号     
            int icomp_statu = int.Parse(this.txt23.SelectedValue);//状态
            string strcomp_Remark = this.txt22.Text.Trim();//备注

            //非空验证
            ArrayList txtBoxArray = new ArrayList();
            txtBoxArray.Add(this.txt1);
            txtBoxArray.Add(this.txt2);
            txtBoxArray.Add(this.txt3);
            txtBoxArray.Add(this.txt5);
            txtBoxArray.Add(this.txt6);
            txtBoxArray.Add(this.txt8);
            txtBoxArray.Add(this.txt10);
            txtBoxArray.Add(this.txt11);

            ClsSystemSetDAL cls_System = new ClsSystemSetDAL();
            string strError = cls_System.FieldValidator(txtBoxArray);

            if (strError == "")
            {
                ClsCorporationDAL cls_CorporationSet = new ClsCorporationDAL();

                Boolean bolIsCussee = cls_CorporationSet.AddCorporation(strcomp_ID, strcomp_Name, strcomp_desc,
                    strcomp_eng, strcomp_boss, strcomp_tel1, strcomp_tel2, strcomp_fax1, strcomp_fax2, strcomp_address, strcomp_post, strcomp_email,
                    strcomp_website, strcomp_bank, strcomp_accno, strcomp_taxno,
                    strUserIDD, icomp_statu, strcomp_Remark);

                if (bolIsCussee)
                {
                    this.GetCorporationSets();//重新绑定

                    ClsMenuDAL cls_Menu = new ClsMenuDAL();

                    txt2.Text = txt3.Text = txt5.Text = txt6.Text = txt7.Text = txt8.Text = txt9.Text = txt10.Text = "";
                    txt11.Text = txt12.Text = txt13.Text = txt14.Text = txt15.Text = txt16.Text = txt22.Text = "";

                    string strCode = cls_Menu.GetSystemCode("0", "00", "", 47);

                    if (strCode != "Error")
                    {
                        this.txt1.Text = strCode;
                        this.lblJs.Text = "<script>document.getElementById('" + this.txt2.ClientID + "').select();ocument.getElementById('" + this.txt2.ClientID + "').focus()</script>";
                    }
                    else
                    {
                        this.panAddRs.Visible = false;
                    }
                }
                else
                {
                    this.lblJs.Text = "<script>alert('新增企业信息失败，请重试！')</script>";
                }
            }
            else
            {
                this.lblJs.Text = "<script>alert('" + strError + "')</script>";
            }
        }
        else
        {
            this.Page.Session.Remove("SetOrGetUserID");
            this.lblJs.Text = "<script>parent.window.location.href='../index.aspx'</script>";
        }
    }

    public void UpDateCorporationSetInfo(object sender, EventArgs e)
    {
        ClsCorporationDAL cls_CorporationSet = new ClsCorporationDAL();
        ImageButton ibtn = (ImageButton)sender;
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        string strUserIDD = cls_Property.SetOrGetUserID;
        int intCommandName = Int32.Parse(ibtn.CommandName);
        if (strUserIDD != "")
        {
            if (intCommandName == 1)//确认
            {
                int intCount = this.dgrdResult.Items.Count;

                for (int i = 0; i < intCount; i++)
                {
                    CheckBox chkBox = (CheckBox)this.dgrdResult.Items[i].FindControl("chkSelect");

                    if (chkBox.Checked)
                    {
                        bool is_audit = bool.Parse(this.dgrdResult.Items[i].Cells[2].Text.Trim());

                        if (!is_audit)
                        {
                            TextBox txtBox = (TextBox)this.dgrdResult.Items[i].FindControl("comp_id");

                            Boolean bolIsCussee = cls_CorporationSet.AuditStatCorporation(txtBox.Text.Trim(), intCommandName, strUserIDD);

                            if (!bolIsCussee)
                            {
                                this.lblJs.Text = "<script>alert('确认企业信息失败，请重试！')</script>";
                            }
                        }
                        else
                        {
                            this.lblJs.Text = "<script>alert('此记录已确认！')</script>";
                        }
                    }
                }

                this.GetCorporationSets();//重新绑定
            }
            else//取消确认，编辑，取消编辑，保存编辑
            {
                int intIndex = Int32.Parse(ibtn.CommandArgument);

                CheckBox chk = (CheckBox)this.dgrdResult.Items[intIndex].FindControl("chkSelect");
                TextBox comp_id = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_id");
                TextBox comp_name = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_name");
                TextBox comp_desc = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_desc");
                TextBox comp_boss = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_boss");
                TextBox comp_tel1 = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_tel1");
                TextBox comp_tel2 = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_tel2");
                TextBox comp_fax1 = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_fax1");
                TextBox comp_fax2 = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_fax2");
                TextBox comp_address = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_address");
                TextBox comp_post = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_post");
                TextBox comp_email = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_email");
                TextBox comp_website = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_website");
                TextBox comp_bank = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_bank");
                TextBox comp_accno = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_accno");
                TextBox comp_taxno = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_taxno");
                TextBox comp_statut = (TextBox)this.dgrdResult.Items[intIndex].FindControl("comp_statut");
                DropDownList comp_statu = (DropDownList)this.dgrdResult.Items[intIndex].FindControl("comp_statu");
                TextBox remark = (TextBox)this.dgrdResult.Items[intIndex].FindControl("remark");
                ImageButton ibtnEdit = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnEdit");
                ImageButton ibtnCan = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnCan");
                ImageButton ibtnSer = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnSer");
                ImageButton ibtnOAudit = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnOAudit");

                if (intCommandName == 0)//取消确认
                {
                    Boolean bolIsCussee = cls_CorporationSet.AuditStatCorporation(comp_id.Text.Trim(), intCommandName, strUserIDD);

                    if (bolIsCussee)
                    {
                        this.GetCorporationSets();//重新绑定
                    }
                    else
                    {
                        this.lblJs.Text = "<script>alert('取消确认企业信息失败，请重试！')</script>";
                    }
                }
                else if (intCommandName == 2)//编辑
                {
                    chk.Visible = ibtnEdit.Visible = comp_statut.Visible = false;
                    ibtnCan.Visible = ibtnSer.Visible = comp_statu.Visible = true;
                    comp_name.ReadOnly = comp_desc.ReadOnly = comp_boss.ReadOnly = comp_tel1.ReadOnly = comp_tel2.ReadOnly = false;
                    comp_fax1.ReadOnly = comp_fax2.ReadOnly = comp_address.ReadOnly = comp_post.ReadOnly = comp_email.ReadOnly = false;
                    comp_website.ReadOnly = comp_bank.ReadOnly = comp_accno.ReadOnly = comp_taxno.ReadOnly = remark.ReadOnly = false;

                    comp_name.BorderWidth = comp_desc.BorderWidth = comp_boss.BorderWidth = comp_tel1.BorderWidth = comp_tel2.BorderWidth = 1;
                    comp_fax1.BorderWidth = comp_fax2.BorderWidth = comp_address.BorderWidth = comp_post.BorderWidth = comp_email.BorderWidth = 1;
                    comp_website.BorderWidth = comp_bank.BorderWidth = comp_accno.BorderWidth = comp_taxno.BorderWidth = remark.BorderWidth = 1;

                    //让第一个文本框获取焦点
                    this.lblJs.Text = "<script>document.getElementById('" + comp_name.ClientID + "').select();document.getElementById('" + comp_name.ClientID + "').focus()</script>";
                }
                else if (intCommandName == 3)//取消编辑
                {
                    this.GetCorporationSets();//重新绑定
                }
                else//保存编辑
                {
                    //非空验证
                    ArrayList txtBoxArray = new ArrayList();
                    txtBoxArray.Add(comp_name);
                    txtBoxArray.Add(comp_desc);
                    txtBoxArray.Add(comp_boss);
                    txtBoxArray.Add(comp_tel1);
                    txtBoxArray.Add(comp_fax1);
                    txtBoxArray.Add(comp_address);
                    txtBoxArray.Add(comp_post);

                    ClsSystemSetDAL cls_System = new ClsSystemSetDAL();
                    string strError = cls_System.FieldValidator(txtBoxArray);

                    if (strError == "")
                    {
                        Boolean bolIsCussee = cls_CorporationSet.UpDateCorporation(comp_id.Text.Trim(), comp_name.Text.Trim(),
                                        comp_desc.Text.Trim(), "", comp_boss.Text.Trim(), comp_tel1.Text.Trim(), comp_tel2.Text.Trim()
                                        , comp_fax1.Text.Trim(), comp_fax2.Text.Trim(), comp_address.Text.Trim(), comp_post.Text.Trim(), comp_email.Text.Trim(),
                                        comp_website.Text.Trim(), comp_bank.Text.Trim(), comp_accno.Text.Trim(), comp_taxno.Text.Trim(), int.Parse(comp_statu.SelectedValue),
                                        remark.Text.Trim());

                        if (bolIsCussee)
                        {
                            this.GetCorporationSets();//重新绑定
                        }
                        else
                        {
                            this.lblJs.Text = "<script>alert('修改企业信息失败，请重试！')</script>";
                        }
                    }
                    else
                    {
                        this.lblJs.Text = "<script>alert('" + strError + "')</script>";
                    }
                }
            }
        }
        else
        {
            this.Page.Session.Remove("SetOrGetUserID");
            this.lblJs.Text = "<script>parent.window.location.href='../index.aspx'</script>";
        }
    }

    public void lbtnDelete_Click(object sender, EventArgs e)
    {
        int intCommandName = Int32.Parse(((LinkButton)sender).CommandName);

        this.DeleteCorporationSetInfo(intCommandName);
    }

    private void DeleteCorporationSetInfo(int CommandName)
    {
        ClsCorporationDAL cls_CorporationSet = new ClsCorporationDAL();

        if (CommandName == 1 || CommandName == -1)
        {
            int intCount = this.dgrdResult.Items.Count;

            for (int i = 0; i < intCount; i++)
            {
                CheckBox chkBox = (CheckBox)this.dgrdResult.Items[i].FindControl("chkSelect");

                if (chkBox.Checked)
                {
                    bool is_audit = bool.Parse(this.dgrdResult.Items[i].Cells[2].Text.Trim());

                    if (!is_audit)
                    {
                        TextBox txtBox = (TextBox)this.dgrdResult.Items[i].FindControl("comp_id");

                        Boolean bolIsCussee = cls_CorporationSet.DeleteCorporation(txtBox.Text.Trim(), CommandName);

                        if (!bolIsCussee)
                        {
                            this.lblJs.Text = "<script>alert('作废企业信息失败，请重试！')</script>";
                        }
                    }
                    else
                    {
                        this.lblJs.Text = "<script>alert('此记录已确认，不能作废！')</script>";
                    }
                }
            }
        }

        this.GetCorporationSets();//重新绑定
    }

    private void GetCorporationSets()
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();

        string strUserID = cls_Property.SetOrGetUserID;

        if (strUserID != "")
        {
            ClsCorporationDAL cls_CorporationSet = new ClsCorporationDAL();
            DataSet dst = cls_CorporationSet.GetCorporations();

            if (dst != null && dst.Tables[0].Rows.Count > 0)
            {
                cls_Property.SetOrGetCorporationDataSet = dst;

                this.BindCorporationSetsByDataView(dst, 0);
            }
            else
            {
                this.dgrdResult.CurrentPageIndex = 0;
                this.dgrdResult.DataSource = null;
                this.dgrdResult.DataBind();
                this.lblRsCounts.Text = "共0条记录";
                this.lblPageCounts.Text = "共0页";
                this.lblCurrPage.Text = "当前第0页";
                this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = this.lbtnNext.Enabled = this.lbtnEnd.Enabled = this.txtGo.Enabled = false;
                this.lblRsCounts.ForeColor = this.lblPageCounts.ForeColor = this.lblCurrPage.ForeColor = this.lblGoTxt1.ForeColor = this.lblGoTxt2.ForeColor = Color.FromArgb(172, 168, 153);
            }
        }
        else
        {
            this.Page.Session.Remove("SetOrGetUserID");
            this.lblJs.Text = "<script>parent.window.location.href='../index.aspx'</script>";
        }
    }

    private void BindCorporationSetsByDataView(DataSet dst, int CurrPageIndex)
    {
        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            this.dgrdResult.CurrentPageIndex = CurrPageIndex;
            this.dgrdResult.DataSource = dst;
            this.dgrdResult.DataBind();

            this.lblRsCounts.Text = "共" + dst.Tables[0].Rows.Count + "条记录";
            this.lblPageCounts.Text = "共" + this.dgrdResult.PageCount + "页";
            this.lblCurrPage.Text = "当前第" + (this.dgrdResult.CurrentPageIndex + 1) + "页";
            this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = this.lbtnNext.Enabled = this.lbtnEnd.Enabled = this.txtGo.Enabled = true;
            this.lblRsCounts.ForeColor = this.lblPageCounts.ForeColor = this.lblCurrPage.ForeColor = this.lblGoTxt1.ForeColor = this.lblGoTxt2.ForeColor = Color.FromArgb(78, 78, 78);

            if (this.dgrdResult.PageCount == 1)
            {
                this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = this.lbtnNext.Enabled = this.lbtnEnd.Enabled = this.txtGo.Enabled = false;
                this.lblGoTxt1.ForeColor = this.lblGoTxt2.ForeColor = Color.FromArgb(172, 168, 153);
            }
            else if (this.dgrdResult.CurrentPageIndex == this.dgrdResult.PageCount - 1)
            {
                this.lbtnNext.Enabled = this.lbtnEnd.Enabled = false;
            }
            else if (this.dgrdResult.CurrentPageIndex == 0)
            {
                this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = false;
            }
        }
    }

    protected void ibtnSearch_Click(object sender, ImageClickEventArgs e)
    {
        string strKey = this.txtKey.Text.Trim();

        if (strKey != "" && strKey != "查询关键字")
        {
            ClsCorporationDAL cls_CorporationSet = new ClsCorporationDAL();
            DataSet dst = cls_CorporationSet.SearchCorporations(strKey);

            if (dst != null && dst.Tables[0].Rows.Count > 0)
            {
                ClsPropertyDAL cls_Property = new ClsPropertyDAL();
                cls_Property.SetOrGetCorporationDataSet = dst;

                this.BindCorporationSetsByDataView(dst, 0);
            }
            else
            {
                this.lblJs.Text = "<script>alert('搜索结果为空！')</script>";
            }
        }
        else
        {
            this.lblJs.Text = "<script>alert('请输入搜索关键字！')</script>";
        }
    }

    protected void txtGo_TextChanged(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_CorporationSet = new ClsPropertyDAL();
        DataSet dst = cls_CorporationSet.SetOrGetCorporationDataSet;

        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            string strIndex = this.txtGo.Text.Trim();
            this.txtGo.Text = String.Empty;

            if (strIndex != "")
            {
                try
                {
                    int intIndex = Int32.Parse(strIndex) - 1;

                    if (intIndex >= 0 && intIndex < this.dgrdResult.PageCount)
                    {
                        this.BindCorporationSetsByDataView(dst, intIndex);
                    }
                    else
                    {
                        this.lblJs.Text = "<script>alert('请输入正确的页码数！')</script>";
                    }
                }
                catch
                {
                    this.lblJs.Text = "<script>alert('请输入数字类型的页码！')</script>";
                }
            }
            else
            {
                this.lblJs.Text = "<script>alert('请输入要跳转的页码！')</script>";
            }
        }
    }

    protected void dgrdResult_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        if (e.Item.ItemIndex != -1)
        {
            Boolean Comp_statu = Boolean.Parse(e.Item.Cells[1].Text.Trim());
            string strIs_audit = e.Item.Cells[2].Text.Trim();

            CheckBox chkbox = (CheckBox)e.Item.FindControl("chkSelect");
            TextBox remark = (TextBox)e.Item.FindControl("remark");
            ImageButton ibtnEdit = (ImageButton)e.Item.FindControl("ibtnEdit");
            ImageButton ibtnCan = (ImageButton)e.Item.FindControl("ibtnCan");
            ImageButton ibtnSer = (ImageButton)e.Item.FindControl("ibtnSer");
            ImageButton ibtnOAudit = (ImageButton)e.Item.FindControl("ibtnOAudit");
            TextBox comp_statut = (TextBox)e.Item.FindControl("comp_statut");
            DropDownList comp_statu = (DropDownList)e.Item.FindControl("comp_statu");
            System.Web.UI.WebControls.Image is_audit = (System.Web.UI.WebControls.Image)e.Item.FindControl("is_audit");
            comp_statu.SelectedIndex = (!Comp_statu) ? 0 : 1;
            comp_statut.Text = comp_statut.ToolTip = comp_statu.SelectedItem.Text;

            //修改按回车提交
            if (remark.ReadOnly)
            {
                ((TextBox)e.Item.FindControl("comp_tel1")).Attributes.Add("onblur", "if(value.Trim() != '' && ! /(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(value)) {alert('电话号码一格式不正确！');this.value='';this.select();this.focus();}");
                ((TextBox)e.Item.FindControl("comp_tel2")).Attributes.Add("onblur", "if(value.Trim() != '' && ! /(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(value)) {alert('电话号码二格式不正确！');this.value='';this.select();this.focus();}");
                ((TextBox)e.Item.FindControl("comp_fax1")).Attributes.Add("onblur", "if(value.Trim() != '' && ! /(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(value)) {alert('传真号码一格式不正确！');this.value='';this.select();this.focus();}");
                ((TextBox)e.Item.FindControl("comp_fax2")).Attributes.Add("onblur", "if(value.Trim() != '' && ! /(^[0-9]{3,4}-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^([0-9]{3,4})[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(value)) {alert('传真号码二格式不正确！');this.value='';this.select();this.focus();}");
                ((TextBox)e.Item.FindControl("comp_post")).Attributes.Add("onblur", "if(value.Trim() != '' && ! /^[1-9]\\d{5}$/.test(value)) {alert('邮政编码格式不正确！');this.value='';this.select();this.focus();}");
                ((TextBox)e.Item.FindControl("comp_email")).Attributes.Add("onblur", "if(value.Trim() != '' && ! (new RegExp(/^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$/).test(value))) {alert('邮箱格式不正确！');this.value='';this.select();this.focus();}");
                remark.Attributes.Add("onkeydown", "if(event.keyCode == 13){document.getElementById('" + ibtnSer.ClientID + "').click();}");
            }

            string strButtonEdit = this.hidButtonEdit.Value;
            string strButtonOAudit = this.hidButtonOAudit.Value;

            if (strIs_audit == "False")
            {
                if (strButtonEdit.Trim() == "1")
                {
                    if (this.panAudit.Visible || this.panDelete.Visible)
                    {
                        chkbox.Visible = true;
                    }

                    ibtnEdit.Visible = true;
                }
                else if (this.panAudit.Visible || this.panDelete.Visible)
                {
                    chkbox.Visible = true;
                }

                //chkbox.Visible = ibtnEdit.Visible = true;
                //ibtnOAudit.Visible = ibtnCan.Visible = ibtnSer.Visible = false;
                //is_audit.ImageUrl = "../App_Images/ico/6.gif";
            }
            else
            {
                ibtnOAudit.Visible = true;

                if (strButtonOAudit.Trim() != "5")
                {
                    ibtnOAudit.Enabled = false;
                    ibtnOAudit.ImageUrl = "../App_Images/ico/17.gif";
                }

                //ibtnOAudit.Visible = true;
                //chkbox.Visible = ibtnEdit.Visible = ibtnCan.Visible = ibtnSer.Visible = false;
                //is_audit.ImageUrl = "../App_Images/ico/7.gif";
            }
        }
    }

    protected void ibtnDelete0_Click(object sender, ImageClickEventArgs e)
    {
        int intCommandName = Int32.Parse(((ImageButton)sender).CommandName);

        this.DeleteCorporationSetInfo(intCommandName);
    }

    protected void imgAdd_Click(object sender, ImageClickEventArgs e)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();

        string strUserID = cls_Property.SetOrGetUserID;

        if (strUserID != "")
        {
            ClsMenuDAL cls_Menu = new ClsMenuDAL();

            string strCode = cls_Menu.GetSystemCode("0", "00", "", 47);

            if (strCode != "Error")
            {
                this.txt1.Text = strCode;
                this.txt17.Text = strUserID;
                this.txt18.Text = DateTime.Now.ToString();
                this.panAddRs.Visible = true;
                this.lblJs.Text = "<script>document.getElementById('" + this.txt2.ClientID + "').select();document.getElementById('" + this.txt2.ClientID + "').focus()</script>";
            }
            else
            {
                this.lblJs.Text = "<script>alert('添加记录失败，请重试！')</script>";
            }
        }
        else
        {
            this.Page.Session.Remove("SetOrGetUserID");
            this.lblJs.Text = "<script>parent.window.location.href='../index.aspx'</script>";
        }
    }

    protected void imgRef_Click(object sender, ImageClickEventArgs e)
    {
        this.GetCorporationSets();
    }

    protected void imgCancel_Click(object sender, ImageClickEventArgs e)
    {
        this.panAddRs.Visible = false;

        ClsMenuDAL cls_Menu = new ClsMenuDAL();

        string strCode = cls_Menu.GetSystemCode("1", "00", txt1.Text.Trim(), 47);
    }
}
